//package com.vast.system.shiro;
//
//
//import com.vast.admin.annotation.CurrentManager;
//import com.vast.common.core.domain.entity.SysUser;
//import org.apache.shiro.authz.UnauthorizedException;
//import org.springframework.core.MethodParameter;
//import org.springframework.web.bind.support.WebDataBinderFactory;
//import org.springframework.web.context.request.NativeWebRequest;
//import org.springframework.web.context.request.RequestAttributes;
//import org.springframework.web.method.support.HandlerMethodArgumentResolver;
//import org.springframework.web.method.support.ModelAndViewContainer;
//
//
///**
// *  增加方法注入，将含有 @CurrentUser 注解的方法参数注入当前登录用户
// * @author zhaohao
// * @since 2018-10-24
// */
//public class CurrentUserMethodArgumentResolver implements HandlerMethodArgumentResolver {
//    @Override
//    public boolean supportsParameter(MethodParameter parameter) {
//        return parameter.getParameterType().isAssignableFrom(SysUser.class)
//                && parameter.hasParameterAnnotation(CurrentManager.class);
//    }
//
//    @Override
//    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
//    	//获取验证拦截器里设置的当前登录用户信息
//        SysUser user = (SysUser) webRequest.getAttribute("currentManager", RequestAttributes.SCOPE_REQUEST);
//        if (user == null) {
//            throw new UnauthorizedException("获取用户信息失败");
//        }
//        return user;
//    }
//}
